/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.myapp.struts;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author Rodriguez
 */
public class OpcionAction extends org.apache.struts.action.Action {

    private static final String AGREGAR = "agregar";
    private static final String MODIFICAR = "modificar";
    private static final String ELIMINAR = "eliminar";

    /**
     * This is the action called from the Struts framework.
     *
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @throws java.lang.Exception
     * @return
     */
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        String opcion = ((OpcionForm) form).getTareaRealizar();
        if (opcion.equals("a")) {
            return mapping.findForward(AGREGAR);
        } else if (opcion.equals("m")) {
            return mapping.findForward(MODIFICAR);
        }
        //la única opción que queda es que sea "e"
        return mapping.findForward(ELIMINAR);
    }
}
